package com.gardenguell.salad.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.gardenguell.salad.R;
import com.gardenguell.salad.ui.activity.ConfigActivity;
import com.gardenguell.salad.ui.activity.LoginActivity;
import com.gardenguell.salad.ui.activity.MainActivity;

/**
 * Created by absurd on 2015/11/25.
 */
public class WelcomeFragment extends BaseFragment{
    private int position;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if(getArguments()!=null){
            position = getArguments().getInt("position");
        }

        ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_welcome, container, false);
        ImageView insImageView = (ImageView) rootView.findViewById(R.id.iv_welcome_instruction);
        ImageView saladbarImageView = (ImageView)rootView.findViewById(R.id.iv_saladbar);
        TextView instruction1 = (TextView)rootView.findViewById(R.id.tv_instruction1);
        TextView instruction2 = (TextView)rootView.findViewById(R.id.tv_instruction2);
        Button btn = (Button)rootView.findViewById(R.id.begin);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(WelcomeFragment.this.getBaseActivity(), LoginActivity.class));
                WelcomeFragment.this.getBaseActivity().finish();
            }
        });





        switch(position){
            case 0:
                btn.setVisibility(View.GONE);
                saladbarImageView.setVisibility(View.VISIBLE);
                insImageView.setImageResource(R.mipmap.welcome_instruction_1);
                instruction1.setText(R.string.instruction1);
                break;
            case 1:
                btn.setVisibility(View.GONE);
                saladbarImageView.setVisibility(View.VISIBLE);
                insImageView.setImageResource(R.mipmap.welcome_instruction_2);
                instruction1.setText(R.string.instruction21);
                instruction2.setText(R.string.instruction22);
                break;
            case 2:
                btn.setVisibility(View.VISIBLE);
                saladbarImageView.setVisibility(View.GONE);
                insImageView.setImageResource(R.mipmap.welcome_instruction_3);
                instruction1.setText(R.string.instruction31);
                instruction2.setText(R.string.instruction32);
                break;
        }
        return rootView;
    }


}
